<?php

include('template.php');

$allTeams = getAllTeamsInDraft($_SESSION['team']->draftID);
$teamID = $_GET['id'] ?  $_GET['id'] : $_SESSION['team']->id;
$currentTeam = $_SESSION['team'];
$dropdown = "<select class='team-select' name='team-select'>";
$dropdown = $dropdown."<option value=''>Select A Team...</option>";
foreach($allTeams as $t)
{
	$dropdown = $dropdown."<option value='".$t->id."'>".$t->name."</option>";
	if ($t->id == $teamID)
	{
		$currentTeam = $t;
	}
}
$dropdown = $dropdown."</select>";

echo "<div class='team-header'>";
	echo "<span class='teamName'>".$currentTeam->name."</span>";
	echo "<span class='team-selector'>".$dropdown."</span>";
echo "</div>";


$players = getPlayersForTeam($teamID);

if ($players)
{
	echo "<table>";
		echo "<thead>"; 
		echo "<tr>";
			echo "<th scope='col'>RANK</th>";
			echo "<th scope='col'>POS</th>";
			echo "<th scope='col'>NAME</th>";
			echo "<th scope='col'>TEAM</th>";
		echo "</tr>";  
	echo "</thead>";
	echo "<tbody>";
	foreach ($players as $p)
	{
		print $p->getDisplayFormat();
	}
	echo "</tbody>";
	echo "</table>";
}

?>
<script type='text/javascript' src='teamswitch.js'></script>
</body>
</html>